package com.jay.media.music.ui.util

import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.media.MediaMetadataRetriever

/**
 * @author xuzhou4
 * @date 2022/2/14
 */
object MediaUtils {

    fun loadCover(mediaUri: String): Bitmap? {
        val mediaMetadataRetriever = MediaMetadataRetriever()
        mediaMetadataRetriever.setDataSource(mediaUri)
        var picture = mediaMetadataRetriever.embeddedPicture
        return if (picture == null) null else BitmapFactory.decodeByteArray(
            picture,
            0,
            picture.size
        )
    }
}